---
layout: example
categories: example/v1.0.0
version: v1.0.0
title: TopoJSON data
description: Loading and parsing TopoJSON data with Leaflet-Omnivore
tags:
  - omnivore
---
<script src='{{site.tileApi}}/mapbox.js/plugins/leaflet-omnivore/v0.2.0/leaflet-omnivore.min.js'></script>

<div id='map'></div>

<script>
var map = L.mapbox.map('map')
    .setView([40, -80], 5)
    .addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));

// Omnivore will AJAX-request this file behind the scenes and parse it:
// note that there are considerations:
// - The file must either be on the same domain as the page that requests it,
//   or both the server it is requested from and the user's browser must
//   support CORS.

// Internally this function uses the TopoJSON library to decode the given file
// into GeoJSON.
var usLayer = omnivore.topojson('{{site.baseurl}}/assets/data/world-110m.json')
    .addTo(map);
</script>
